package com.yl.chainStore.payrule.coupons

import com.yl.chainStore.entity.pay.PayCustomerOrder
import com.yl.chainStore.payrule.common.DiscountComputeOrderResultVo
import com.yl.common.control.returnSuccess

/**
 * 优惠卷规则
 */
abstract class CouponsRuleService {

	/**
	 * 计算订单
	 * @param order 订单
	 * @param isUse 是否使用（计算时不使用，结算，付款使用）
	 * @param ids     选中的优惠卷
	 */
	 fun computeOrder(order: PayCustomerOrder,
	                 isUse: Boolean,
	                 useId:Boolean,
	                 ids: List<Long>?): DiscountComputeOrderResultVo{
	 	return if(useId){
	 		if(ids != null && ids.isNotEmpty()){
			    computeOrderUseId(order,isUse,ids)
	 		}else{
			    DiscountComputeOrderResultVo(returnSuccess(),order)
	 		}
	 	}else{
		    computeOrderNotUseId(order,isUse)
	 	}
	 }

	abstract fun  computeOrderUseId(order: PayCustomerOrder,
	                  isUse: Boolean,
	                  ids: List<Long>): DiscountComputeOrderResultVo

	abstract fun  computeOrderNotUseId(order: PayCustomerOrder,
	                                isUse: Boolean): DiscountComputeOrderResultVo


}
